package cn.kgc.springbootday02.controller;

import cn.kgc.springbootday02.entity.User;
import cn.kgc.springbootday02.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/5/25
 * @Description:
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;
    @GetMapping
    public List<User> getList(){
        return userService.list();
    }

    @GetMapping("{id}")
    public User getOne(@PathVariable("id") Integer id){
        return userService.getById(id);
    }


}
